﻿
/// <reference path="Container.js" />
/// <reference path="_namespace.js" />

/*****************************************************************************
Ajax library class definition. Kevin Robinson 2006.
Class: ajax.components.SplitterBar
/*****************************************************************************/


ajax.lang.addNamespace("ajax.components");


//-----------------------------------------------------------------------------
ajax.components.SplitterBar = function(doc, parentNode, layerName, splitterType) // Constructor
{
    ajax.components.SplitterBar.superConstructor.call(this, doc, parentNode, layerName, 0, 0);
    
    this.splitterType   = splitterType;
    this.dragController = null;
    
    // Sort out our size, depending on the type of splitter bar we are...    
    var splitterTypes = ajax.lang.safeCall("ajax.components.Splitter", "getSplitterTypes");
    switch (this.splitterType)
    {
        case splitterTypes.Vertical:
        {
            this.units.size.height          = "%";
            this.width                      = 4;
            this.height                     = 100;           
            this.layerStyle.cursor          = "col-resize";
            break;
        }
        case splitterTypes.Horizontal:
        {
            this.units.size.width           = "%";
            this.width                      = 100;
            this.height                     = 4; 
            this.layerStyle.cursor          = "row-resize";
            break;
        }
        default:
            break
    }
    
    // Styles
    this.layerStyle.position        = "absolute";
    this.layerStyle.backgroundColor = "#000000";
    this.layerStyle.filter          = "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
    this.layerStyle.opacity         = "0.3";
    
}

//-----------------------------------------------------------------------------
ajax.lang.extend("ajax.components.SplitterBar", "ajax.components.Container"); // Inherit
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
ajax.components.SplitterBar.prototype.create = function()
{
    ajax.components.SplitterBar.superClass.create.call(this);
    
    // Create our dragController
    this.dragController = ajax.lang.safeNew("ajax.components.DragController", 
        document, this.layer);
        
    // We want to know when we have been moved, so we can update our settings and fire our "onMove" event
    this.dragController.getEvent(this.window, "onDragEnd").addListener(function(e)
        {             
            this.setPosition(e.x, e.y);            
        }.bind(this)
    );    
}

//-----------------------------------------------------------------------------
ajax.components.SplitterBar.prototype.toString = function()
{
    return "ajax.components.SplitterBar";
}

//-----------------------------------------------------------------------------
ajax.components.SplitterBar.cast = function(obj)
{///<returns type="ajax.components.SplitterBar"/>
    return obj;
}